<?php
declare (strict_types=1);

namespace app\admin\controller;

use app\common\builder\TableBuilder;
use app\common\builder\TableFront;
use think\App;

class UserLevel extends Base
{
    //主键，默认为id
    protected $pk = 'id';

    //主模型
    protected $model = '\app\common\model\UserLevel';

    public function index()
    {
        return $this->setTable();
    }

    public function setTable()
    {
        //构建table
        $tableFront = TableFront::getInstance()
            ->addRow(['field' => 'id', 'sort' => true, 'title' => 'ID', 'width' => 80])
            ->addRow(['field' => 'title', 'title' => '名称'])
            ->addRow(['fixed' => 'right', 'align' => 'center', 'toolbar' => '#barDemo', 'title' => '操作', 'width' => 100])
            ->clearTable();

        return TableBuilder::getInstance()
            ->addColumns($tableFront)
            ->addRightButtons(['edit' => ['width' => 600, 'height' => 500]])
            ->setSearch($this->setSearch(), false)
            ->fetch();
    }

    public function setSearch()
    {
        return TableFront::getInstance()
            ->setSearch(['title', '名称', 'input', '', '', '', 'like']);
    }
}